﻿using System;
using Wicresoft.RDW.Utility;
using Wicresoft.RDW.Presentation;
using System.Linq;

namespace Wicresoft.RDW.Manage
{
    public partial class FeedbackQuestion : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lsvQuestion.DataSource = QusetionPresent.GetList();
                lsvQuestion.DataBind();
            }
        }
        protected void lsvQuestion_ItemDeleting(object sender, System.Web.UI.WebControls.ListViewDeleteEventArgs e)
        {
            int i = e.ItemIndex;
            string ID = this.lsvQuestion.DataKeys[i]["QuestionId"].ToString();
            var questionId = Int32.Parse(ID);
            AnnouncementPresent.Delete(questionId);
            //AnnouncementGW_DataBind();
        }

        protected void lsvQuestion_ItemUpdating(object sender, System.Web.UI.WebControls.ListViewUpdateEventArgs e)
        {

        }


        //protected void lbtnAddQuestion_Click(object sender, EventArgs e)
        //{
        //    lblQuestionCN.Visible = true;
        //    txtQuestionCN.Visible = true;
        //    lblQuestionEN.Visible = true;
        //    txtQuestionEN.Visible = true;
        //    lbtnSunmit.Visible = true;
        //    lbtnAddAnswer.Visible = true;
        //}

        //protected void lbtnAddAnswer_Click(object sender, EventArgs e)
        //{
        //    lblAnswerCN.Visible = true;
        //    txtAnswerCN.Visible = true;
        //    lblAnswerEN.Visible = true;
        //    txtAnswerEN.Visible = true;
        //    lbtnSubmitAnswer.Visible = true;
        //}

        //protected void lbtnSunmit_Click(object sender, EventArgs e)
        //{
        //    Model.Question question = new Model.Question()
        //    {
        //        Question_CN = Server.HtmlEncode(txtQuestionCN.Text),
        //        Question_EN = Server.HtmlEncode(txtQuestionEN.Text),
        //        Status = (int)QuestionStatus.Active
        //    };
        //    QusetionPresent.Create(question);

        //    lblQuestionCN.Visible = false;
        //    lblQuestionEN.Visible = false;
        //    txtQuestionCN.Visible = false;
        //    txtQuestionEN.Visible = false;
        //    lbtnSunmit.Visible = false;
        //    lbtnAddQuestion.Visible = false;
        //    gwQuestion.DataSource = QusetionPresent.GetList();
        //    gwQuestion.DataBind();
        //}

    //    protected void lbtnSubmitAnswer_Click(object sender, EventArgs e)
    //    {
    //        var question = QusetionPresent.GetList().LastOrDefault();
    //        Model.Answer answer = new Model.Answer()
    //        {
    //            Answer_CN = Server.HtmlEncode(txtAnswerCN.Text),
    //            Answer_EN = Server.HtmlEncode(txtAnswerEN.Text),
    //            QuestionId = question.QuestionId
    //        };
    //        AnswerPresent.Create(answer);
    //        gwAnswer.DataSource = AnswerPresent.GetList(p => p.QuestionId == question.QuestionId);
    //        gwAnswer.DataBind();
    //        lblAnswerCN.Visible = false;
    //        txtAnswerCN.Visible = false;
    //        lblAnswerEN.Visible = false;
    //        txtAnswerEN.Visible = false;
    //        lbtnSubmitAnswer.Visible = false;
    //    }
    }
}